<style scoped src="./index.scss" lang="scss" rel="stylesheet/scss"></style>
<template src="./index.html"></template>
<script>
import ForgetPwd from "../ForgetPwd/index";
import Register from "../Register/index";
export default {
  data() {
    return {
      username: "",
      password: "",
      loading: false,
    };
  },

  components: {},

  methods: {
    async getUserInfo() {
      // 获取用户信息

      if (_data) {
        this.userInfo = _data.data;
      }
    },
    async submit() {
      if (!this.username || !this.password) {
        this.$vFN.Tools.messageError("请填写完整的账号和密码");
        return;
      }

      this.loading = true;
      // 获取token
      let _data = await this.$vFN.Http.post(
        {
          isSid: false,
          isToken: false,
          isLoading: false,
          isErrorAlert: false,
          url: "mall-site-portal/portal-login/login",
          data: {
            username: this.username,
            password: this.password,
          },
        },
        window
      );

      if (_data._ok) {
        this.$vFN.Tools.setToken({
          expiresIn: _data.data.expiresIn,
          token: _data.data.token,
          tokenHead: _data.data.tokenHead,
        });
        let _info = await this.$vFN.Http.post(
          {
            isSid: false,
            url: "mall-site-portal/portal-login/info",
          },
          window
        );
        if (_info._ok) {
          // this.$vFN.Tools.messageSuccess("登录成功")

          this.$router.push({
            path: "/site",
            query: {
              sid: _info.data.platformId + "",
            },
          });
        }
      } else {
        this.$vFN.Tools.messageError("账号或密码错误");
      }

      this.loading = false;
    },

    forgetPwd() {
      ForgetPwd.init();
    },

    register() {
      Register.init();
    },
  },

  computed: {},
  mounted() {
    const h = this.$createElement;

    // this.$message({
    //   message: "222"
    // });
  },
  activated() {},
};
</script>